/*
 * Copyright 2010-2012 Susanta Tewari. <freecode4susant@users.sourceforge.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package test.coalescent.data;

import commons.util.test.DefaultTDMeasure;
import test.commons.core.DataTestDataProbability;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;

import static test.coalescent.data.DataTestDataInstances.*;

/**
 * @author Susanta Tewari
 */
public class DataTestDataProbabilitys {

    /** Field description */
    private static Collection<DataTestDataProbability> k69TestDataProbInstances;

    /** Field description */
    private static Collection<DataTestDataProbability> kc64TestDataProbInstances;

    /**
     * Constructs ...
     *
     */
    private DataTestDataProbabilitys() {}

    /**
     * Method description
     *
     *
     * @return
     */
    @SuppressWarnings("ReturnOfCollectionOrArrayField")
    public static Collection<DataTestDataProbability> getKC64TestDataProbInstances() {

        if (kc64TestDataProbInstances != null) {
            return kc64TestDataProbInstances;
        }

        kc64TestDataProbInstances = new ArrayList<>(20);

        /**
         * Note for theta == 1, the Ewen`s sampling formula becomes:
         * P(a) = Product: (1...n) Inverse( a(j)! . j^a(j) )
         */


        // hein data probs
        // Pattern: 1^2
        kc64TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(1).divide(new BigDecimal(2)), heinKC64DataUIDPrefix + "D-2-2"));


        // Pattern: 1^1_2^1
        kc64TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(1).divide(new BigDecimal(2)), heinKC64DataUIDPrefix + "D-3-1"));


        // Pattern: 1^2
        kc64TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(1).divide(new BigDecimal(2)), heinKC64DataUIDPrefix + "D-3-2"));


        // Pattern: 1^1_2^1
        kc64TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(1).divide(new BigDecimal(2)), heinKC64DataUIDPrefix + "D-3-3"));


        // Pattern: 1^1_2^1
        kc64TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(1).divide(new BigDecimal(2)), heinKC64DataUIDPrefix + "D-4-1"));


        // Pattern: 1^3
        kc64TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(1).divide(new BigDecimal(6)), heinKC64DataUIDPrefix + "D-4-2"));


        // Pattern: 2^2
        kc64TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(1).divide(new BigDecimal(8)), heinKC64DataUIDPrefix + "D-4-3"));


        // Pattern: 1^1_2^1
        kc64TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(1).divide(new BigDecimal(2)), heinKC64DataUIDPrefix + "D-4-4"));


        // Pattern: 1^3
        kc64TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(1).divide(new BigDecimal(6)), heinKC64DataUIDPrefix + "D-5-1"));


        // Pattern: 1^2_2^1
        kc64TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(1).divide(new BigDecimal(4)), heinKC64DataUIDPrefix + "D-5-2"));


        // Pattern: 2^2
        kc64TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(1).divide(new BigDecimal(8)), heinKC64DataUIDPrefix + "D-5-3"));


        // Pattern: 1^3
        kc64TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(1).divide(new BigDecimal(8)), heinKC64DataUIDPrefix + "D-5-4"));


        // Pattern: 1^2_2^1
        kc64TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(1).divide(new BigDecimal(4)), heinKC64DataUIDPrefix + "D-6-1"));


        // Pattern: 1^2_2^1
        kc64TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(1).divide(new BigDecimal(4)), heinKC64DataUIDPrefix + "D-6-2"));


        // Pattern: 1^2_2^1
        kc64TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(1).divide(new BigDecimal(4)), heinKC64DataUIDPrefix + "D-6-3"));


        // Pattern: 1^1_2^2
        kc64TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(1).divide(new BigDecimal(8)), heinKC64DataUIDPrefix + "D-7-1"));


        // Pattern: 1^4
        kc64TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(1).divide(new BigDecimal(24)), heinKC64DataUIDPrefix + "D-7-2"));


        // Pattern: 1^3_2^1
        kc64TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(1).divide(new BigDecimal(12)), heinKC64DataUIDPrefix + "D-8-1"));

        return kc64TestDataProbInstances;
    }

    /**
     * Method description
     *
     *
     * @return
     */
    @SuppressWarnings("ReturnOfCollectionOrArrayField")
    public static Collection<DataTestDataProbability> getK69TestDataProbInstances() {

        if (k69TestDataProbInstances != null) {
            return k69TestDataProbInstances;
        }

        k69TestDataProbInstances = new ArrayList<>(20);


        // hein data probs
        k69TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(1).divide(new BigDecimal(4)), heinK69DataUIDPrefix + "D-2-2"));
        k69TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(7).divide(new BigDecimal(36)), heinK69DataUIDPrefix + "D-3-1"));
        k69TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(1).divide(new BigDecimal(16)), heinK69DataUIDPrefix + "D-3-2"));
        k69TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(1).divide(new BigDecimal(12)), heinK69DataUIDPrefix + "D-3-3"));
        k69TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(55).divide(new BigDecimal(1296)), heinK69DataUIDPrefix + "D-4-1"));
        k69TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(7).divide(new BigDecimal(81)), heinK69DataUIDPrefix + "D-4-2"));
        k69TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(10).divide(new BigDecimal(144)), heinK69DataUIDPrefix + "D-4-3"));
        k69TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(1).divide(new BigDecimal(48)), heinK69DataUIDPrefix + "D-4-4"));
        k69TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(37).divide(new BigDecimal(1944)), heinK69DataUIDPrefix + "D-5-1"));
        k69TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(157).divide(new BigDecimal(5184)), heinK69DataUIDPrefix + "D-5-2"));
        k69TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(41).divide(new BigDecimal(2592)), heinK69DataUIDPrefix + "D-5-3"));
        k69TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(1).divide(new BigDecimal(216)), heinK69DataUIDPrefix + "D-5-4"));
        k69TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(3310).divide(new BigDecimal(497664)),
                heinK69DataUIDPrefix + "D-6-1"));
        k69TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(419).divide(new BigDecimal(62208)), heinK69DataUIDPrefix + "D-6-2"));
        k69TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(65).divide(new BigDecimal(20736)), heinK69DataUIDPrefix + "D-6-3"));
        k69TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(6662).divide(new BigDecimal(2488320)),
                heinK69DataUIDPrefix + "D-7-1"));
        k69TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(307).divide(new BigDecimal(248832)),
                heinK69DataUIDPrefix + "D-7-2"));
        k69TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(14337).divide(new BigDecimal(31104000)),
                heinK69DataUIDPrefix + "D-8-1"));


        // spouge probs
        k69TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(305).divide(new BigDecimal(31104)), spougeK69DataUIDPrefix + "J-1"));
        k69TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(26).divide(new BigDecimal(720)), spougeK69DataUIDPrefix + "J-2"));
        k69TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(552).divide(new BigDecimal(17280)), spougeK69DataUIDPrefix + "J-3"));


        // tewari probs
        k69TestDataProbInstances.add(new DefaultTestDataProbability(new BigDecimal(6.2764E-5),
                tewariK69DataUIDPrefix + "T-1"));
        k69TestDataProbInstances.add(new DefaultTestDataProbability(new BigDecimal(1.1931E-6),
                tewariK69DataUIDPrefix + "T-2"));
        k69TestDataProbInstances.add(
            new DefaultTestDataProbability(
                new BigDecimal(0.0014783513017261082), tewariK69DataUIDPrefix + "T-3"));

        return k69TestDataProbInstances;
    }

    /**
     * Class description
     *
     *
     * @version        Enter version here..., 12/10/09
     * @author         Susanta Tewari
     */
    private static class DefaultTestDataProbability extends DefaultTDMeasure
            implements DataTestDataProbability {

        /** Field description */
        private final BigDecimal probability;

        DefaultTestDataProbability(BigDecimal probability, String testDataUID) {

            super(testDataUID);

            this.probability = probability;
        }

        /**
         * Method description
         *
         *
         * @return
         */
        @Override
        public BigDecimal getProbability() {
            return probability;
        }
    }
}
